
<%@ include file="/html/portlet/ext/registration/init.jsp" %>

<liferay-ui:error exception="<%= SecretPinException.class %>" message="SecretPin Already exists in Database" />

<%

PortletURL url1 = renderResponse.createActionURL();
	url1.setWindowState(WindowState.NORMAL);
	url1.setParameter("struts_action", "/ext/registration/addRegistration");
	url1.setParameter("cmd", "approveSchool");
	
PortletURL url2 = renderResponse.createActionURL();
	url2.setWindowState(WindowState.NORMAL);
	url2.setParameter("struts_action", "/ext/registration/addRegistration");
	url2.setParameter("cmd", "pendingSchool");
	
PortletURL url3 = renderResponse.createActionURL();
	url3.setWindowState(WindowState.NORMAL);
	url3.setParameter("struts_action", "/ext/registration/addRegistration");
	url3.setParameter("cmd", "rejectSchool");
	
%>
<script type="text/javascript">

function validateSecrePin() {

	var secretPin = document.getElementById("secretPin").value;
	
	if(secretPin == null || secretPin == "") {
		alert('Please Enter Secret Pin')
		document.getElementById("secretPin").focus();
		return false;
	}
	else {
		submit1('<%=url1.toString()%>');
	}
}

function submit1(url) {
		var frm = document.<portlet:namespace/>fm;
		submitForm(frm,url);
	}
	
</script>

<% 
	School school = (School)request.getAttribute("school");
	
	SimpleDateFormat sdf = new SimpleDateFormat("MMM,yyyy");
	
	Long countryId = Long.parseLong(school.getCountry());
   	Long regionId = Long.parseLong(school.getState());
   	Long cityId = Long.parseLong(school.getCity());
   	
   	Integer button = null;
   	String button1 = (String) request.getAttribute("Button");
   	if( button1 != null) {
   		button = Integer.parseInt(button1);
   	}	
   	
%>
<form name="<portlet:namespace/>fm"  method="POST">
 
	<table width='100%' class='portlet-box' style='border:1px solid LightSteelBlue;' cellspacing="0" cellpadding="2">
	
	<tr class='results-header'>
		<td class='portlet-font' colspan='3' style='font-weight:bold;height:25px' nowrap>
		<liferay-ui:message key="school-details" />
		</td>
	</tr>
	
	<tr class = "portlet-section-body results-row alt">
		<td width='40%'><liferay-ui:message key="school-name" /></td>
		<td width='60%'> <%= school.getName() %> </td>
	</tr>
	
	<tr class = "portlet-section-body results-row">
		<td><liferay-ui:message key="date-Of-Establishment" /></td>
		<td> <%= sdf.format(school.getDateOfEstablishment()) %> </td>
	</tr>
	
	<tr class = "portlet-section-body results-row alt">
		<td><liferay-ui:message key="street-address1" /></td>
		<td> <%= school.getStreet1() %> </td>
	</tr>
	
	<tr class = "portlet-section-body results-row">
		<td><liferay-ui:message key="street-address2" /></td>
		<td> <%= school.getStreet2() %> </td>
	</tr>
	
	<tr class = "portlet-section-body results-row alt">
		<td><liferay-ui:message key="street-address3" /></td>
		<td> <%= school.getStreet3() %> </td>
	</tr>
	
	<tr class = "portlet-section-body results-row">
		<td><liferay-ui:message key="board" /></td>
		<td> <%= school.getBoard().equals("Others") ?school.getOthers():school.getBoard() %> </td>
	</tr>
	
	<tr class = "portlet-section-body results-row alt">
		<td><liferay-ui:message key="country" /></td>
		<td> <%= CityLocalServiceUtil.countryName(countryId)  %> </td>
	</tr>
	
	<tr class = "portlet-section-body results-row">
		<td><liferay-ui:message key="state" /></td>
		<td> <%= CityLocalServiceUtil.stateName(regionId) %> </td>
	</tr>
	
	<tr class = "portlet-section-body results-row alt">
		<td><liferay-ui:message key="city" /></td>
		<td> <%= CityLocalServiceUtil.cityName(cityId) %> </td>
	</tr>
	
	<tr class = "portlet-section-body results-row">
		<td><liferay-ui:message key="pin-code" /></td>
		<td> <%= school.getPinCode() %> </td>
	</tr>
	
	<tr class = "portlet-section-body results-row alt">
		<td><liferay-ui:message key="contact-no" /></td>
		<td> <%= school.getContactNo() %> </td>
	</tr>
	
	<tr class = "portlet-section-body results-row">
		<td><liferay-ui:message key="web-site" /></td>
		<td> <%= school.getWebsite() %> </td>
	</tr>
	
	<tr class = "portlet-section-body results-row alt">
		<td><liferay-ui:message key="email-id" /></td>
		<td> <%= school.getCpEmailAddress() %> </td>
	</tr>
	
	<tr class = "portlet-section-body results-row">
		<td><liferay-ui:message key="no-Of-students" /></td>
		<td> <%= school.getNoOfStudents() %> </td>
	</tr>
	
	<tr class = "portlet-section-body results-row alt">
		<td><liferay-ui:message key="no-Of-teachers" /></td>
		<td> <%= school.getNoOfTeachers() %> </td>
	</tr>
	
	<tr class='results-header'>
		<td><liferay-ui:message key="concerned-person-details" /></td>
		<td></td>
	</tr>
	
	<tr class = "portlet-section-body results-row alt">
		<td><liferay-ui:message key="first-name" /></td>
		<td> <%= school.getCpFirstName() %> </td>
	</tr>
	
	<tr class = "portlet-section-body results-row">
		<td><liferay-ui:message key="middle-name" /></td>
		<td> <%= school.getCpMiddleName() %> </td>
	</tr>
	
	<tr class = "portlet-section-body results-row alt">
		<td><liferay-ui:message key="last-name" /></td>
		<td> <%= school.getCpLastName() %> </td>
	</tr>
	
	<tr class = "portlet-section-body results-row">
		<td><liferay-ui:message key="birthday" /></td>
		<td> <%= sdf.format(school.getBirthDay()) %> </td>
	</tr>
	
	<tr class = "portlet-section-body results-row alt">
		<td><liferay-ui:message key="gender" /></td>
		<td> <%= !school.getCpGender() ? "Femail" : "Male" %> </td>
	</tr>
	
	<tr class = "portlet-section-body results-row">
		<td><liferay-ui:message key="job-title" /></td>
		<td> <%= school.getJobTitle() %> </td>
	</tr>
	
	<tr class = "portlet-section-body results-row alt">
		<td><liferay-ui:message key="contact-no" /></td>
		<td> <%= school.getCpContactNo() %> </td>
	</tr>
	<c:choose>
		<c:when test="<%= (Validator.isNotNull(button) && (button == 1) || (button == 2) || (button == 3))   %>">
			<tr class = "portlet-section-body results-row">
				<td><liferay-ui:message key="secret-pin" /></td>
				<td> <input type ="text" name ="secretPin" id="secretPin"> </td>
			</tr>
		</c:when>
		<c:otherwise>
			<tr class = "portlet-section-body results-row alt">
				<td><liferay-ui:message key="secret-pin" /></td>
				<td> <%= school.getSecretPin() %> </td>
			</tr>
		</c:otherwise>			
	</c:choose>
	
	<tr class='results-header'>
		<td><liferay-ui:message key="login-details" /></td>
		<td></td>
	</tr>
	
	<tr class = "portlet-section-body results-row alt">
		<td><liferay-ui:message key="user-name" /></td>
		<td> <%= school.getLoginId() %> </td>
	</tr>
</table>
<br>
<table align='center'>
	<tr class="portlet-form-button">
		<td>     
	    	<input type="hidden" name="schoolId" value="<%= school.getSchoolId() %>"/>
	    	<c:if test="<%= (Validator.isNotNull(button) && (button == 1))   %>">
		        <input type="submit" value="<liferay-ui:message key="approve" />" onClick="return validateSecrePin();"/>
		    	<input type="submit" value="<liferay-ui:message key="pending" />" onClick="submit1('<%=url2.toString()%>');"/>
		    	<input type="submit" value="<liferay-ui:message key="reject" />" onClick="submit1('<%=url3.toString()%>');"/>
	    	</c:if>
	    	<c:if test="<%= (Validator.isNotNull(button) && (button == 2))   %>">
	    		 <input type="submit" value="<liferay-ui:message key="approve" />" onClick="return validateSecrePin();"/>
	    		 <input type="submit" value="<liferay-ui:message key="reject" />" onClick="submit1('<%=url3.toString()%>');"/>
	    	</c:if>
	    	 <c:if test="<%= (Validator.isNotNull(button) && (button == 3))   %>">
	    	  <input type="submit" value="<liferay-ui:message key="approve" />" onClick="return validateSecrePin();"/>
	    	  <input type="submit" value="<liferay-ui:message key="pending" />" onClick="submit1('<%=url2.toString()%>');"/>
	    	</c:if>
	    	<input type="button"  value='<liferay-ui:message key="back" />' onClick='history.go(-1)'>
		</td>
	</tr>
</table>
</form>

